<template>
  <div class="agentList divBox">
    <el-card class="box-card" shadow="hover">
      <el-table
        v-loading="disLoading"
        :data="tableCompanyList"
        style="width: 100%"
        size="mini"
        class="table"
        @selection-change="handleSelectionChange"
      >
        <el-table-column
          prop="id"
          label="ID"
          align="center"
          min-width="135"
        ></el-table-column>
        <el-table-column
          prop="name"
          label="公司名称"
          align="center"
          min-width="120"
        ></el-table-column>
        <el-table-column
          prop="mobile"
          label="电话"
          align="center"
          min-width="120"
        ></el-table-column>

        <el-table-column
          prop="content"
          label="公司介绍"
          align="center"
          min-width="160"
        > <template slot-scope="{ row }"><div class="content" v-html="row.content"></div></template>
        
      </el-table-column>
        <el-table-column
          prop="isShow"
          label="是否显示公司"
          align="center"
          min-width="120"
        >
          <template slot-scope="{ row }">
            <div>
              {{ row.isShow ? "显示" : "隐藏" }}
            </div>
          </template>
        </el-table-column>

        <el-table-column label="操作" width="230" fixed="right" align="center">
          <template slot-scope="{ row }">
            <el-button type="text" size="small" @click="edit(row.id)"
              >选择公司</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <div class="spreadBox">
        <pagination
          v-show="pagination.total > 0"
          :total="pagination.total"
          :page.sync="pagination.page"
          :limit.sync="pagination.limit"
          :page-sizes="[10, 20, 30, 50]"
          @pagination="replyChange"
        />
      </div>
    </el-card>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { getRouteId } from "@/utils/auth";
import {
  getCompanyListApi,
  // activitieDeleteApi,
  deleteCompanyApi,
  patchCompanyMobileApi
} from "@/api/company";
export default {
  name: "Index",
  props: {
    editId: {
      type: Number,
    },
    editRow: {
      type: Number,
    }
  },
  data() {
    return {
      grid: {
        xl: 5,
        lg: 7,
        md: 12,
        sm: 12,
        xs: 24,
      },
      disForm: {
        keyword: "",
        roleId: "",
      },
      pagination: {
        page: 1,
        limit: 10,
        total: 100,
      },
      tableCompanyList: [],
      del: [],
      disLoading: false,
      disabled: true,
    };
  },
  computed: {
    selectedId(){
        return getRouteId()
    }
  },
  mounted() {
    this.getCompanyList();
  },
  methods: {
    /**
     * 行选中时
     */
    handleSelectionChange(val) {
      this.$set(
        this,
        "del",
        val.map((item) => item.id)
      );
      console.log(this.del);
      if (val.length > 0) this.$set(this, "disabled", false);
      else this.$set(this, "disabled", true);
    },

    
    //选择活动id
    edit(id){
        console.log("id>>>>>>",id);
        let data={
          editRow:this.editRow,
          id:id
        }
        this.$emit('getCompanyList',data)
        this.$emit('close')
      },
    /**
     * 获取公司列表
     */
    getCompanyList() {
      console.log(">>>>>>>>>>>>");
      getCompanyListApi(this.selectedId,{
        pageNumber: this.pagination.page,
        pageSize: this.pagination.limit,
        orderby: "Id desc",
        isShow: -1,
        isDel: 0,
      }).then((res) => {
        this.$set(this, "tableCompanyList", res.data);
        this.pagination.total = res.head ? res.head.totalCount : 0;
      });
    },
    replyChange(reply) {
      this.$set(this.pagination, "page", reply.page);
      this.$set(this.pagination, "limit", reply.limit);
      console.log("pagination", this.pagination);
      this.getCompanyList();
    },
  },
};
</script>

<style lang="scss" scoped>
.agentList {
  .taoBox_img {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;

    img {
      width: 100%;
      height: 100%;
    }
  }
  .taoBoxs_img {
    // width: 36px;
    // height: 36px;
    border-radius: 4px;
    // overflow: hidden;
    cursor: pointer;

    img {
      margin-right: 5px;
      width: 36px;
      height: 36px;
    }
    video {
      margin-right: 5px;
      width: 50px;
      height: 50px;
    }
  }

  .el-dropdown-link {
    cursor: pointer;
    color: #409eff;
    font-size: 12px;
  }

  .el-icon-arrow-down {
    font-size: 12px;
  }
}
</style>

<style lang="scss">
.el-dialog.cusDialogCls,
.el-dialog.editAgentDialogCls {
  max-width: 960px;
}

.el-dialog.promotionOrderDialogCls {
  max-width: 900px;
}
</style>